<?php
/**
 * 存储服务端公钥到 wp_options 表
 * 直接运行此文件即可
 */

// 加载 WordPress
require_once 'wp-load.php';

// 服务端公钥
$public_key = "-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApqD3IoqJN+SXYO/u62aK
f82Iy7u4omiP8/fngod8S29/Z3U/vubQafKx15ujyMNQxW0cIelhyD4+det/EvHV
GZ/lbvD1Q5cfcYSfNdZYBXB6E9EIjAYnlBDLz1Hys+HEYdd0uc5T+hsniavPUcTW
NXMW6OgSm7TdRs+jF/WNqF6DwBRavD1RcsEPiZhoXhATEL3IUmQJYsjCCaxhV7hV
clPZiUPyEgodS7JdlBwRjorcjuxStrnnZIot2R7rOd3otqZ6CIo4wIuXujs9wfDQ
l2m07KdiwAZFGpAbsrYT9ec976u+n1qUhGxsTR9nWNiaCd0o/xpXKkQWefT1Q2up
nwIDAQAB
-----END PUBLIC KEY-----";

// 存储到 wp_options 表
$result = update_option('spider_server_public_key', $public_key);

if ($result) {
    echo "✅ 公钥已成功存储到 wp_options 表\n";
    echo "选项名: spider_server_public_key\n";
    echo "公钥长度: " . strlen($public_key) . " 字符\n";
} else {
    echo "❌ 公钥存储失败\n";
}

// 验证存储
$stored_key = get_option('spider_server_public_key', '');
if ($stored_key === $public_key) {
    echo "✅ 验证成功：存储的公钥与原始公钥一致\n";
} else {
    echo "❌ 验证失败：存储的公钥与原始公钥不一致\n";
}

// 同时设置缓存
set_transient('spider_server_public_key', $public_key, 3600);
echo "✅ 公钥已缓存1小时\n";

echo "\n=== 完成 ===\n";
echo "现在可以测试许可证功能了\n";
?>
